//
//  BHCircleListModel.swift
//  BigHealth
//
//  Created by 布丁 on 2021/8/4.
//

import UIKit

class BHCircleListModel {
    var userAvatar: String = ""
    var userName: String = ""
    var title: String = ""
    var userId: String = ""
    var circleUrl: String = "" // 展示图片  resourceType = 1
    var extraUrl: String = "" // 视屏首帧图片  resourceType = 2
    var circleId: String = "" // id
    
    var resourceType: Int = 1 // 类型 (1-图片 2-视屏)
    var supportNumber: Int = 0 // 点赞数
    var likeFlag: Int = 0 // 是否点赞  0:否  1:是
    
    func parseDic(_ dic: [String:Any])  {
        self.userAvatar = BHJsonTool.decodeStringFromDic(dic: dic, key: "userAvatar")
        self.userName = BHJsonTool.decodeStringFromDic(dic: dic, key: "userName")
        self.title = BHJsonTool.decodeStringFromDic(dic: dic, key: "title")
        self.userId = BHJsonTool.decodeStringFromDic(dic: dic, key: "userId")
        self.circleUrl = BHJsonTool.decodeStringFromDic(dic: dic, key: "circleUrl")
        self.extraUrl = BHJsonTool.decodeStringFromDic(dic: dic, key: "extraUrl")
        self.circleId = BHJsonTool.decodeStringFromDic(dic: dic, key: "id")

        self.resourceType = BHJsonTool.decodeIntFromDic(dic: dic, key: "resourceType")
        self.supportNumber = BHJsonTool.decodeIntFromDic(dic: dic, key: "supportNumber")
        self.likeFlag = BHJsonTool.decodeIntFromDic(dic: dic, key: "likeFlag")

    }
    
    lazy var textHeight: CGFloat = {
        let halfW = (UIScreen.width-40)/2.0 - 1

        let height = self.title.calSizeOfText(font: .systemFont(ofSize: 14, weight: .bold), size: CGSize(width: halfW - 15, height: CGFloat.greatestFiniteMagnitude)).height
        return ceil(height)
    }()
    
}
